import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'


import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';


import { createSvgIconsPlugin }  from 'vite-plugin-svg-icons'
import {resolve} from 'path'

// const path = require('path');
import path from 'path'

let timeStamp = new Date().getTime();

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),

    createSvgIconsPlugin({
      iconDirs: [resolve(process.cwd(), 'src/icons')],
      symbolId: 'icon-[name]'
    }),
  ],
  base: './',
  resolve: {
    // 配置路径别名
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 9527,
    open: true,
  },
  build: {
    rollupOptions: {
      output: {
        chunkFileNames: `static/js/[name]-[hash]-${timeStamp}.js`,
        entryFileNames: `static/js/[name]-[hash]-${timeStamp}.js`,
        assetFileNames: `static/[ext]/[name]-[hash]-${timeStamp}.[ext]`,
      }
    }
  }
})
